package com.app.yc.ifapp.entity;

import android.os.Parcel;
import android.os.Parcelable;

import com.app.yc.ifapp.adapter.IExpandableGroup;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

/**
 * 作者：TanTun
 * 时间：2017/3/17
 * 邮箱：32965926@qq.com
 * 描述：房间实体类定义
 */

public class Room<TChild> implements IExpandableGroup<TChild>, Parcelable {
    String room_Id;
    String room_Name;
    String room_Type;
    List<Term> terms;
    List<IrDevice> irDevices;
    List<TChild> child;

    public String getRoom_Id() {
        return room_Id;
    }

    public void setRoom_Id(String room_Id) {
        this.room_Id = room_Id;
    }

    public String getRoom_Name() {
        return room_Name;
    }

    public void setRoom_Name(String room_Name) {
        this.room_Name = room_Name;
    }

    public String getRoom_Type() {
        return room_Type;
    }

    public void setRoom_Type(String room_Type) {
        this.room_Type = room_Type;
    }

    public List<Term> getTerms() {
        return terms;
    }

    public void setTerms(List<Term> terms) {
        this.terms = terms;
    }

    public List<IrDevice> getIrDevices() {
        return irDevices;
    }

    public void setIrDevices(List<IrDevice> irDevices) {
        this.irDevices = irDevices;
    }

    @Override
    public List<TChild> getChild() {
        return child;
    }

    @Override
    public void setChild(List<TChild> child) {
        this.child = child;
    }


    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.room_Id);
        dest.writeString(this.room_Name);
        dest.writeString(this.room_Type);
        dest.writeTypedList(this.terms);
        dest.writeTypedList(this.irDevices);
        dest.writeList(this.child);
    }

    public Room() {
    }

    protected Room(Parcel in) {
        this.room_Id = in.readString();
        this.room_Name = in.readString();
        this.room_Type = in.readString();
        this.terms = in.createTypedArrayList(Term.CREATOR);
        this.irDevices = in.createTypedArrayList(IrDevice.CREATOR);
        this.child = new ArrayList<>();
        Type type = ((ParameterizedType) getClass().getGenericSuperclass())
                .getActualTypeArguments()[0];
        in.readList(this.child, type.getClass().getClassLoader());
    }

    public static final Parcelable.Creator<Room> CREATOR = new Parcelable.Creator<Room>() {
        @Override
        public Room createFromParcel(Parcel source) {
            return new Room(source);
        }

        @Override
        public Room[] newArray(int size) {
            return new Room[size];
        }
    };
}
